<template>
  <div id="OnSale">
    <h2 class="shopTitle" v-show="inSaleGoodsNum>0">
      <p>
        <a
          href="javascript:void(0)"
          class="link"
          @click="enterShopCarList('ShopCarList',miniStoreId)"
        >在售车辆</a>
        <a href="javascript:void(0)" @click="enterShopCarList('ShopCarList',miniStoreId)">
          <span>
            共
            <i>{{inSaleGoodsNum}}</i>辆 >>
          </span>
        </a>
      </p>
    </h2>
    <ul class="carList horizontal" v-show="inSaleGoodsNum<=3 &&inSaleGoodsNum>0 ">
      <li v-for="(item,index) in goodsVo" :key="index">
        <a href="javascript:void(0)" @click="getCarDetail('CarDetail',item.goodsId)">
          <div class="carImgBg" :style="{backgroundImage:'url('+item.imgUrl+')'}"></div>
          <p class="ellipsis-2">{{item.carModelName}}</p>
          <div class="carInfo">
            <span class="price">{{(item.retailPrice/10000).toFixed(2)}}万</span>
            <span class="city">{{item.carCityName}}</span>
          </div>
        </a>
      </li>
    </ul>
    <div class="verticalBox" v-show="inSaleGoodsNum>3">
      <ul class="vertical carList">
        <li v-for="(item,index) in (goodsVo||'').slice(0,5)" :key="index">
          <a
            href="javascript:void(0)"
            class="clearfix"
            @click="getCarDetail('CarDetail',item.goodsId)"
          >
            <div class="carImgBg" :style="{backgroundImage:'url('+item.imgUrl+')'}"></div>
            <div class="carInfo">
              <p class="type ellipsis-2 PingFang">{{item.carModelName}}</p>
              <p
                class="city ellipsis-1"
              >{{item.carCityName}} / {{item.registerTime}} {{(item.mileage/10000).toFixed(2)}}万公里</p>
              <span class="price">{{(item.retailPrice/10000).toFixed(2)}}万</span>
              <div class="dataBox">
                <span class="size">{{item.dischargeLevel}}</span>
                <span>{{item.updateTime}}</span>
              </div>
            </div>
          </a>
        </li>
      </ul>
      <div class="more">
        <a href="javascript:void(0)" @click="enterShopCarList('ShopCarList',miniStoreId)">查看更多车辆</a>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {};
  },
  props: {
    goodsVo: Array,
    inSaleGoodsNum: Number,
    miniStoreId: Number
  },
  components: {},

  methods: {
    // 进入在售列表
    enterShopCarList(name, miniStoreId) {
      this.$router.push({
        name: name,
        query: {
          miniStoreId: miniStoreId
        }
      });
    },
    // 点击跳转车辆详情
    getCarDetail(name, orderId) {
      this.$router.push({
        name: name,
        query: {
          orderId: orderId
        }
      });
    }
  },
  created() {}
};
</script>
<style type="text/css" lang='scss'>
#OnSale {
  margin-top: 10px;
  .carList {
    li {
      background: #fff;
      padding: 15px;
      margin-bottom: 15px;
      a {
        width: 100%;
      }
    }
  }
  .horizontal {
    li {
      background: #fff;

      p {
        color: #303030;
        font-size: 1.416667rem;
        margin-bottom: 10px;
      }
      .carInfo {
        display: flex;
        justify-content: space-between;
        align-items: center;
        .price {
          color: #0098ff;
          font-size: 1.666667rem;
        }
        .city {
          color: #999;
        }
      }
    }
    .carImgBg {
      width: 100%;
      height: 200px;
      border-radius: 10px;
    }
  }
  .vertical {
    li {
      border-bottom: 1px solid rgba(248, 248, 248, 1);
      margin-bottom: 0px;
      a {
        padding-top: 10px;
        width: 100%;
        display: flex;
        padding-bottom: 10px;

        .carInfo {
          width: 68%;
          float: left;
          height: 105px;
        }
      }
      .carImgBg {
        float: left;
        width: 28%;
        height: 105px;
        margin-right: 2%;
      }
      p.type {
        height: 34px;
        color: #323232;
        font-size: 1.25rem;
        line-height: 1.4rem;
      }
      p.city {
        color: #666;
        // margin: 2px 0;
        width: 100%;
      }
      span.price {
        color: #0098ff;
        font-size: 1.416667rem;
        font-weight: bold;
        margin-bottom: 2px;
      }
      .dataBox {
        display: flex;
        justify-content: space-between;
        align-items: center;
        span {
          color: rgba(153, 153, 153, 1);
          font-size: 0.916667rem;
        }
        .size {
          color: #666;
          border-radius: 2px;
          border: 1px solid rgba(102, 102, 102, 1);
          padding: 0.5px 3px;
        }
      }
    }
  }
  .more {
    background: #fff;
    padding: 15px 0;
    a {
      display: block;
      width: 150px;
      margin: 0 auto;
      height: 30px;
      text-align: center;
      line-height: 30px;
      border: 1px solid #525252;
      border-radius: 2px;
      font-size: 1.083333rem;
      color: #525252;
    }
  }
}
</style>


